package day17.method;

public class ThreadMethod03 {
    public static void main(String[] args) throws InterruptedException {
        //1.主线程每隔1s，输出 hi，一共 10次2. 当输出到 hi 5 时，启动一个子线程(要求实现Runnable)，每隔1s 输出 hello,等该线程输出10次 hello后，退出
        //3.主线程继续输出 hi,直到主线程退出
        T3 t3 = new T3();
        Thread thread = new Thread(t3);
        for (int i = 1; i <= 10; i++) {
            System.out.println("hi" + i);
            if (i == 5){
                thread.start();
                thread.join();
            }
            Thread.sleep(1000);
        }
    }
}
class T3 implements Runnable{
    @Override
    public void run() {
        for (int i = 1; i <= 10; i++) {
            System.out.println("hello"+i);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
